#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QDockWidget>
#include <QMainWindow>
#include <QMovie>
#include <QtCharts>

#include "agvhardware.h"
#include "battarywidget.h"
#include "blinklabel.h"
#include "digitalkeyboard.h"
#include "endpoint.h"
#include "maindeal.h"
#include "parametersetting.h"
#include "readlog.h"
#include "recordslamroute.h"
#include "udputils.h"
#include "user.h"
#include "userinputui.h"

#include "RViz/rviz.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
  Q_OBJECT

 public:
  MainWindow(int argc, char** argv, QWidget* parent = nullptr);
  ~MainWindow();
  Maindeal* MainDeal();

  void initUI();
  void initData();
  void showBatteryData();

 private:
  Ui::MainWindow* ui;
  Maindeal* maindeal = nullptr;
  // QMovie*         qmovie_left_gear_  = nullptr;  //左动态齿轮
  // QMovie*         qmovie_right_gear_ = nullptr;
  User user_;
  QString black_style_;
  QString white_style_;
  QString red_style_;
  QString green_style_;
  QString orange_style_;
  QThread* thread_1 = nullptr;  // 线程1
  UDPUtils* udp_socket;
  QString edition, Update;

  int argc;
  char** argv;
  bool is_show_system_order = true;  // 允许显示接收系统给的命令
  int data_min_time = 5;             // 数据保存最小时间 单位：日
  bool is_open_keyboard = false;     // 允许打开键盘控制
  bool is_first_start = false;
  bool is_open_record_route = false;
  void initWidget();
  void showSpeed();
  void showNaviInfo();
  void showGearMovie(double leftSpeed, double rightSpeed);
  void checkAndSetAuthority();
  void closeEvent(QCloseEvent* event);
 signals:
  void sigSendCurPoint(const int& x, const int& y, const double& radian);
  void sigSendQrocdePoint(const Point& qrcode, const int& id);

 public slots:
  void sltClearLog();
  void sltShowTips(const QString& tips);
  void sltShowSystemOrder(const QByteArray& tips, const QString& string);
  void sltShowTemporaryOrder(const QByteArray& tips, const QString& string);
  //    void sltRecvKeyEvent( QKeyEvent* e );
  void sltShowSysTips(const QString& ip, const QString& tips);
  void sltChangeModule(int index);

 private slots:
  void slt50msTimer();
  void slt500msTimer();
  void slt1000msTimer();
  void slt30sTimer();
  void on_pushButton_forward_clicked();   //舵轮前进
  void on_pushButton_backward_clicked();  //舵轮后退
  void on_pushButton_left_clicked();     //舵轮左转
  void on_pushButton_right_clicked();    //舵轮右转
  void on_pushButton_stop_clicked();     //舵轮停止
  void on_pushButton_mode_change_clicked();  //模式切换
  void on_pushButton_reset_state_clicked(); //复位状态
  void on_pushButton_man_charge_clicked();  //人工强制充电
  void on_pushButton_window_fullscreen_clicked(); //全屏
  void on_pushButton_window_normal_clicked();  //适应
  void on_pushButton_close_clicked();  //关闭
  void on_pushButton_parm_reset_clicked(); //参数文件色设置
  void on_pushButton_log_read_clicked();
  void on_pushButton_drive_enable_clicked(bool checked);//打开私服使能
  void on_pushButton_init_pose_clicked();
  void on_pushButton_login_clicked();
  void on_pushButton_logout_clicked(); //退出用户
  void on_pushButton_usage_clicked();
  void on_pushButton_read_route_clicked(); //读取激光路线文件
  void on_pushButton_system_order_suspend_clicked(bool checked);
  void on_pushButton_clean_msg_clicked(); //清空消息
  void on_btn_fork_high_upper_clicked();   //货叉上升置高位按钮
  void on_btn_fork_low_down_clicked();    //货叉下降置低位按钮
  void on_btn_fork_stop_clicked();      //货叉停止动作按钮
  void on_pushButton_clear_system_order_clicked();
  void on_pushButton_record_slam_point_clicked();
  void on_pushButton_creat_slamroutemsg_clicked(); //生成路线信息表格
  void on_pushButton_set_goal_clicked(); //设定目标
  void on_pushButton_reset_servo_alarm_clicked();//清除私服报警
  void on_pushButton_cancel_goal_clicked(); //取消任务
  void on_pushButton_man_charge_return_clicked(); //人工强制收回充电
};
#endif  // MAINWINDOW_H
